package com.water.domain;

import java.io.UnsupportedEncodingException;

/**
 * Jquery DataTable参数
 * 
 * @author Administrator
 * 
 */
public class DataTableParameter {

	
	public final static String SECHO = "sEcho";
	
	//过滤前总记录数
	public final static String ITOTALRECORDS = "iTotalRecords";
	
	//过滤后总记录数
	public final static String ITOTALDISPALYRECORDS = "iTotalDisplayRecords";
	
	//结果集
	public final static String AADATA = "aaData";
	
	
	
	/**
	 * DataTable请求服务器端次数
	 */
	public String sEcho;

	/**
	 * 过滤文本
	 */
	public String sSearch;

	/**
	 * 每页显示的数量
	 */
	public int iDisplayLength;

	/**
	 * 分页时每页跨度数量
	 */
	public int iDisplayStart;

	/**
	 * 列数
	 */
	public int iColumns;

	/**
	 * 排序列的数量
	 */
	public int iSortingCols;

	/**
	 * 当前页数
	 */
	public int pageNo;

	/**
	 * 逗号分割所有的列
	 */
	public String sColumns;

	public String getSEcho() {
		return sEcho;
	}

	public void setSEcho(String echo) {
		sEcho = echo;
	}

	public String getSSearch() {
		try {
			sSearch = new String(sSearch.getBytes("iso-8859-1"), "UTF-8");
			return sSearch;
		} catch (UnsupportedEncodingException e) {
		}
		return "";
	}

	public void setSSearch(String search) {
		sSearch = search;
	}

	public int getIDisplayLength() {
		return iDisplayLength;
	}

	public void setIDisplayLength(int displayLength) {
		iDisplayLength = displayLength;
	}

	public int getIDisplayStart() {
		return iDisplayStart;
	}

	public void setIDisplayStart(int displayStart) {
		iDisplayStart = displayStart;
	}

	public int getIColumns() {
		return iColumns;
	}

	public void setIColumns(int columns) {
		iColumns = columns;
	}

	public int getISortingCols() {
		return iSortingCols;
	}

	public void setISortingCols(int sortingCols) {
		iSortingCols = sortingCols;
	}

	public String getSColumns() {
		return sColumns;
	}

	public void setSColumns(String columns) {
		sColumns = columns;
	}

	public int getPageNo() {
		if ((iDisplayStart + 1) % iDisplayLength == 0) {
			pageNo = (iDisplayStart + 1) / iDisplayLength;
		} else {
			pageNo = (iDisplayStart + 1) / iDisplayLength + 1;
		}
		if (pageNo == 0) {
			pageNo = 1;
		}
		return pageNo;
	}

}
